package com.train.mgr.modules.system.entity;

import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;
import java.util.List;
import java.util.stream.Collectors;

/**
 * Treeselect树结构实体类
 *
 * @author cxg
 */
@Data
public class TreeSelect implements Serializable
{
    private static final long serialVersionUID = 1L;

    /** 节点ID */
    @ApiModelProperty(name = "id", value = "节点ID(公司组织ID)")
    private Long id;

    /** 节点名称 */
    @ApiModelProperty(name = "label", value = "节点名称（公司组织名称）")
    private String label;

    /** 员工人数  */
    @ApiModelProperty(name = "employeeCount", value = "员工人数")
    private String employeeCount;

    /** 子节点 */
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    private List<TreeSelect> children;

    public TreeSelect()
    {

    }

    public TreeSelect(Dept dept)
    {
        this.id = dept.getDeptId();
        this.label = dept.getDeptName();
        this.children = dept.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList());
    }

    public TreeSelect(Menu menu)
    {
        this.id = menu.getId();
        this.label = menu.getName();
       // this.children = menu.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList());
    }
}
